//
//  TableViewRefreshView.h
//  iOSDevelopSDK
//
//  Created by Hayder on 2018/9/28.
//  Copyright © 2018年 Hayder. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MJRefresh/MJRefresh.h>
#import "HHEmptyView.h"
#import "HHBaseSearchBar.h"

@protocol HHTableRefreshViewDelegate <NSObject>

@optional
- (void)tableRefreshDidSearchWithText:(NSString *)searchText;

@end

@interface HHTableRefreshView : UIView <UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,HHEmptyViewDelegate,HHBaseSearchBarDelegate>

@property (nonatomic, weak) id<HHTableRefreshViewDelegate> delegate;

@property (nonatomic, strong) HHEmptyView *emptyView;
/**
 刷新控件部分
 */
@property (nonatomic, assign) NSInteger page;

@property (nonatomic, strong) UITableView *tableView;

@property (nonatomic, strong) NSMutableArray *dataSource;
/**
 空白界面描述
 */
@property (nonatomic, copy) NSString *emptyDescription;
//搜索栏
@property (nonatomic, strong) HHBaseSearchBar *searchBar;
//搜索按钮
@property (nonatomic, strong) NSString *searchText;
//原始数据列表，用于清空搜索栏时，返回上次未搜索前的数据
@property (nonatomic, strong) NSMutableArray *allDatas;
/**
 添加头部视图刷新
 */
- (void)addHeaderRefresh;
/**
 添加尾部视图刷新
 */
- (void)addFooterRefresh;

/**
 添加搜索栏
 */
- (void)addSearchBarWithPlaceHolder:(NSString *)placeHolder;

- (void)loadData;

- (void)loadMoreData;

- (void)beginRefreshing;

- (void)endRefreshing;

/**
 处理返回的数据
 */
- (void)handleData:(NSArray *)data isRefresh:(BOOL) isRefresh;

/**
 处理请求失败的情况
 */
- (void)handleRequestError;

/**
 处理数据错误
 */
- (void)handleErrorWithText:(NSString *)text;

/**
 处理搜索内容
 */
- (void)handleSearchText;

/**
 重新刷新ui
 */
- (void)reloadData;

@end
